package com.jt.aspect;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
/**
 * 切面对象的特征
 * 1、切入点
 * 2、通知方法*/
@Slf4j
@Aspect
@Component
public class LogAspect {
    //@Pointcut中定义切入点表达式
    //表达式中要描述在哪些地方定义切入点
    @Pointcut("@annotation(com.jt.annotation.RequiredLog)")
    public void doLog(){}

    @Around("doLog()")
    public Object doAround(ProceedingJoinPoint jt) throws Throwable {
        log.info("Around.Before {}",System.currentTimeMillis());
        Object result = jt.proceed();
        log.info("Around.After {}",System.currentTimeMillis());
        return result;
    }
}
